package com.order.service.basics;

import com.alibaba.fastjson2.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;

/**
 * FileName: Process.java
 * Author:   徐寿春
 * Date:     2023/2/8 17:23
 * <p>
 * 名称:
 */
@Slf4j
public class ProcessLog {


    public static void infoRequestLog() {
        StackTraceElement[] stackTraceElements = (new Throwable()).getStackTrace();
        assert stackTraceElements[1].getFileName() != null;
        String apiName = stackTraceElements[1].getFileName().replace(".java", "") + "." + stackTraceElements[1].getMethodName();


        log.info("调用:service = {}   参数:request = 空", apiName);

    }


    public static void infoRequestLog(Object o) {

        Assert.notNull(o,"请求参数为空");
        StackTraceElement[] stackTraceElements = (new Throwable()).getStackTrace();
        assert stackTraceElements[1].getFileName() != null;
        String apiName = stackTraceElements[1].getFileName().replace(".java", "") + "." + stackTraceElements[1].getMethodName();

        log.info("调用:service = {}   参数:request = {}", apiName, JSON.toJSONString(o));

    }

}
